package demo01

/**
 * @author xiaoZhao
 * @date 2022/6/6
 * @describe 伴生类
 */
class Student(name: String, var age: Int) {
  def printInfo(): Unit = {
    println(name + " " + age + " " + Student.school)
  }
}

//引入伴生对象
object Student {
  // 伴生对象全局实现变量
  val school: String = "qinghua"

  def main(args: Array[String]): Unit = {
    val lisi = new Student("lisi", 21)
    val wangwu = new Student("wangwu", 22)
    lisi.printInfo()
    wangwu.printInfo()
  }
}